XML is a declarative mechanism for defining data, and XML schema is a declarative mechanism for defining a type of XML document, typically expressed in terms of constraints on the structure and content of documents of that type, above and beyond the basic syntax constraints imposed by XML itself. An XML schema provides a view of the document type at a relatively high level of abstraction.
There are languages developed specifically to express XML schemas. The Document Type Definition (DTD) language, which is native to the XML specification, is a schema language that is of relatively limited capability, but that also has other uses in XML aside from the expression of schemas. Two other very popular, more expressive XML schema languages are XML Schema (W3C) and RELAX NG.
The mechanism for associating an XML document with a schema may vary according to the schema language. The association may be achieved via markup within the XML document itself, or via some external means.
The process of checking to see if an XML document conforms to a schema is called validation, which is separate from XML's core concept of syntactic well-formedness. All XML documents are well-formed, but a document may be valid when an XML parser may check the document for conformance with the document's schema. Documents are considered valid if they conform to the schema with which they have been associated.